package cn.tedu.controller;

import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpSession;
import java.time.LocalDate;


@RestController
@RequestMapping("/home")
public class HomeController {
    //    http://localhost:8080/springmvc1_war/home/index.do
    @GetMapping("index")
    public ModelAndView index(ModelMap map, HttpSession session) {
        //从当前Session中取出登录用户信息
        String loginuser = (String) session.getAttribute("loginuser");
        String date = LocalDate.now().toString();
        map.put("date", date);
        map.put("username", loginuser);
        System.out.println("index()");
        return new ModelAndView("index");
    }
}
